﻿#include <boost/interprocess/containers/vector.hpp>
#include <boost/interprocess/sync/interprocess_mutex.hpp>
#include <boost/interprocess/managed_shared_memory.hpp>

class custom_data {
public:
    typedef boost::interprocess::allocator<int, boost::interprocess::managed_shared_memory::segment_manager> shmem_allocator;
    typedef boost::interprocess::vector<int, shmem_allocator> my_vector;

    custom_data();
    void init(boost::interprocess::managed_shared_memory& segment);

    void add();

    void push_back(int num);

    void print();

private:
    int* a_ptr_ = nullptr;
    boost::interprocess::interprocess_mutex *a_mutex_ptr_ = nullptr;

    my_vector *b_ptr_ = nullptr;
    boost::interprocess::interprocess_mutex *b_mutex_ptr_ = nullptr;
};
